﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using RM.Common;
using RM.DBUtility;
namespace RM.DAL
{
    public partial class RMConfig
    {
        public RMConfig()
        { }
        /// <summary>
        /// 根据ID得到一个实体
        /// </summary>
        /// <param name="id">ID</param>
        /// <returns></returns>
        public Model.RMConfig GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 id,configkey,configvalue,remark");
            strSql.Append(" from X_COnfig");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters ={
                                          new SqlParameter("@id",SqlDbType.Int)};
            parameters[0].Value = id;
            Model.RMConfig model = new Model.RMConfig();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.ConfigKey = ds.Tables[0].Rows[0]["configkey"].ToString();
                model.ConfigValue = ds.Tables[0].Rows[0]["configvalue"].ToString();
                model.Remark = ds.Tables[0].Rows[0]["remark"].ToString();
            }
            return model;
        }
    }
}
